package com.automannn.atm_back.modules.codeGenerator.service.impl;

import com.automannn.atm_back.modules.codeGenerator.entity.TypeMapperGroupEntity;
import com.automannn.atm_back.modules.codeGenerator.mapper.TypeMapperGroupEntityMapper;
import com.automannn.atm_back.modules.codeGenerator.service.TypeMapperGroupEntityService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

/**
 * (GeneratorTypeMapperGroup)表服务实现类
 *
 * @author chenkaihai
 * @since 2020-07-12 17:07:53
 */
@Service
public class TypeMapperGroupEntityServiceImpl implements TypeMapperGroupEntityService {
    @Resource
    private TypeMapperGroupEntityMapper typeMapperGroupEntityMapper;


    /**
     * 查询一个对象
     *
     * @param id return 实例对象
     */
    @Override
    public TypeMapperGroupEntity queryOne(String id) {
        return this.typeMapperGroupEntityMapper.queryById(id);
    }

    /**
     * 查询所有对象
     * <p>
     * return 实例对象
     */
    @Override
    public IPage<TypeMapperGroupEntity> queryAll(Page<TypeMapperGroupEntity> page, TypeMapperGroupEntity generatorTypeMapperGroup) {
        return this.typeMapperGroupEntityMapper.queryAll(page, generatorTypeMapperGroup);
    }

    /**
     * 新增数据
     *
     * @param generatorTypeMapperGroup 实例对象
     * @return 实例对象
     */
    @Override
    public TypeMapperGroupEntity insert(TypeMapperGroupEntity generatorTypeMapperGroup) {
        this.typeMapperGroupEntityMapper.insert(generatorTypeMapperGroup);
        return generatorTypeMapperGroup;
    }

    /**
     * 修改数据
     *
     * @param generatorTypeMapperGroup 实例对象
     * @return 实例对象
     */
    @Override
    public void update(TypeMapperGroupEntity generatorTypeMapperGroup) {
        typeMapperGroupEntityMapper.update(generatorTypeMapperGroup);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.typeMapperGroupEntityMapper.deleteById(id) > 0;
    }

    @Override
    public void deleteBatchByIds(String ids) {
        typeMapperGroupEntityMapper.deleteBatchIds(Arrays.asList(ids.split(",")));
    }
}
